package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.WatermarkConfigls;
import com.hiultra.archive.service.IWatermarkConfiglsService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 水印配置Controller
 * 
 * @author ls
 * @date 2023-08-29
 */
@Api(tags="水印配置Controller")
@RestController
@RequestMapping("/archive/config")
public class WatermarkConfiglsController extends BaseController
{
    @Autowired
    private IWatermarkConfiglsService watermarkConfiglsService;

    /**
     * 查询水印配置列表
     */
    @ApiOperation(value = "查询水印配置列表", notes = "查询水印配置列表")
    @PreAuthorize("@ss.hasPermi('archive:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(WatermarkConfigls watermarkConfigls)
    {
        startPage();
        List<WatermarkConfigls> list = watermarkConfiglsService.selectWatermarkConfiglsList(watermarkConfigls);
        return getDataTable(list);
    }

    /**
     * 导出水印配置列表
     */
    @ApiOperation(value = "导出水印配置列表", notes = "导出水印配置列表")
    @PreAuthorize("@ss.hasPermi('archive:config:export')")
    @Log(title = "水印配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WatermarkConfigls watermarkConfigls)
    {
        List<WatermarkConfigls> list = watermarkConfiglsService.selectWatermarkConfiglsList(watermarkConfigls);
        ExcelUtil<WatermarkConfigls> util = new ExcelUtil<WatermarkConfigls>(WatermarkConfigls.class);
        util.exportExcel(response, list, "水印配置数据");
    }

    /**
     * 获取水印配置详细信息
     */
    @ApiOperation(value = "获取水印配置详细信息", notes = "获取水印配置详细信息")
    @PreAuthorize("@ss.hasPermi('archive:config:query')")
    @GetMapping(value = "/{watermarkId}")
    public AjaxResult getInfo(@PathVariable("watermarkId") Long watermarkId)
    {
        return AjaxResult.success(watermarkConfiglsService.selectWatermarkConfiglsByWatermarkId(watermarkId));
    }

    /**
     * 新增水印配置
     */
    @ApiOperation(value = "新增水印配置", notes = "新增水印配置")
    @PreAuthorize("@ss.hasPermi('archive:config:add')")
    @Log(title = "水印配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WatermarkConfigls watermarkConfigls)
    {
        watermarkConfigls.setCreateBy(getUsername());
        return toAjax(watermarkConfiglsService.insertWatermarkConfigls(watermarkConfigls));
    }

    /**
     * 修改水印配置
     */
    @ApiOperation(value = "修改水印配置", notes = "修改水印配置")
    @PreAuthorize("@ss.hasPermi('archive:config:edit')")
    @Log(title = "水印配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WatermarkConfigls watermarkConfigls)
    {
        watermarkConfigls.setUpdateBy(getUsername());
        return toAjax(watermarkConfiglsService.updateWatermarkConfigls(watermarkConfigls));
    }

    /**
     * 删除水印配置
     */
    @ApiOperation(value = "删除水印配置", notes = "删除水印配置")
    @PreAuthorize("@ss.hasPermi('archive:config:remove')")
    @Log(title = "水印配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{watermarkIds}")
    public AjaxResult remove(@PathVariable Long[] watermarkIds)
    {
        return toAjax(watermarkConfiglsService.deleteWatermarkConfiglsByWatermarkIds(watermarkIds));
    }
}
